/** 
 * projectName:  
 * fileName:  
 * packageName:  
 * date: 
 * copyright(c) 2017-2020 xxx公司
 */
package cn.wxgzh.service.impl;

import cn.itcast.mapper.*;
import cn.itcast.pojo.*;
import cn.itcast.util.CookieUtil;
import cn.wxgzh.service.WxgzhService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**   
 * @title: userServiceImpl.java 
 * @package com.job.service.lmpl 
 * @description: TODO
 * @author: 欧阳辉
 * @date: 2019年1月25日 下午3:21:04 
 * @version: V1.0   
*/
@Slf4j
@Service
public class WxgzhServiceImpl implements WxgzhService {


	@Resource
    horsemanMapper horsemanMapper;


	@Resource
    CookieUtil cookieUtil;

	@Override
	public Map<String,Object> login(String username, String password) {
		//返回Map
		Map<String,Object> map = new HashMap<String, Object>();
		boolean islogin=true;
		horsemanExample hEx = new horsemanExample();
		horsemanExample.Criteria criteria = hEx.createCriteria();
		criteria.andHorsemanNumberEqualTo(username);
		List<horseman> horsemens = horsemanMapper.selectByExample(hEx);
		if(!horsemens.isEmpty()) {
			String pwd = horsemens.get(0).getHorsemanPassword();
			if(password.equals(pwd)) {
				//管理员数据返回前台
				map.put("horsemen",horsemens.get(0));
				map.put("islogin", islogin);
				//System.out.println(template.opsForValue().get(token));
				log.debug(horsemens.get(0).getHorsemanNumber());
			}else {
				islogin = false;
				map.put("horsemen","");
				map.put("islogin", islogin);
				log.debug("密码错误");
			}
		}else {
			islogin = false;
			map.put("horsemen","");
			map.put("islogin", islogin);
			log.debug("用户不存在");
		}
		return map;
	}


}
